import 'package:flutter/material.dart';

class ShopList extends StatelessWidget {
  ShopList({super.key});
  // 1. 提供的数据
  Map orderInfo = {
    'createTime': "2024-08-15 21:49:48",
    'orderState': "待发货",
    'image':
        "https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg",
    'name': "茶水分离杯耐热隔热玻璃杯茶水分离杯耐热隔热玻璃杯",
    'totalNum': 2,
    'curPrice': 119.5,
    'attrsText': "规格: 白色240ml"
  };
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(top: 20),
      width: MediaQuery.of(context).size.width,
      height: 220,
      color: const Color.fromARGB(255, 190, 232, 250),
      child: Column(
        children: [
          //顶部下单时间
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(orderInfo['createTime']),
              Text(
                orderInfo['orderState'],
                style:
                    const TextStyle(color: Color.fromARGB(255, 255, 228, 148)),
              )
            ],
          ),
          const SizedBox(
            height: 10,
          ),
          //商品详情部分
          Row(
            children: [
              //图片
              Image.network(
                orderInfo['image'],
                width: 100,
              ),
              const SizedBox(width: 10),
              //右侧商品文案
              Expanded(
                //弹性布局
                child: Column(
                  //文案列表
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(children: [
                      Expanded(
                        child: Text(
                          orderInfo['name'],
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                        ),
                      ),
                      //数量
                      Padding(
                        padding: const EdgeInsets.only(left: 10, right: 10),
                        child: Text('x ${orderInfo['totalNum']}'),
                      )
                    ]),
                    const SizedBox(height: 10),
                    Text(
                      orderInfo['attrsText'],
                      style: const TextStyle(
                          color: Color.fromARGB(255, 152, 152, 151)),
                    ),
                    const SizedBox(height: 10),
                    Text('￥${orderInfo['curPrice']}'),
                  ],
                ),
              )
            ],
          ),
          //底部合计与按钮
          Container(
            width: MediaQuery.of(context).size.width,
            padding: const EdgeInsets.only(left: 10, right: 10),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                //底部合计与按钮
                Text('合计:￥${orderInfo['totalNum'] * orderInfo['curPrice']}'),
                const SizedBox(height: 10),
                Container(
                  padding: const EdgeInsets.all(5),
                  decoration: BoxDecoration(
                      border: Border.all(color: Colors.black, width: 2)),
                  child: const Text('再次购买'),
                ),
                // ElevatedButton(onPressed: () {}, child: Text('再次购买'))
              ],
            ),
          )
        ],
      ),
    );
  }
}
